import java.util.*;

/**
 * @author LKQ
 * @date 2022/5/13 10:50
 * @description 贪心
 */
public class Solution2 {
    public static void main(String[] args) {

    }
    public int maxIceCream(int[] costs, int coins) {
        Arrays.sort(costs);
        int ans = 0;
        for (int cost: costs) {
            if (coins > cost) {
                coins -= cost;
                ans++;
            }else {
                break;
            }
        }
        return ans;
    }
}
